home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Table / Sources / TblProxy.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.1 KB  |  181 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                TblProxy.cpp
  4. //    Release Version:    $ 1.0d11 $ 
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Table.hpp"
  11.  
  12. // ----- TablePart Includes -----
  13.  
  14. #ifndef TBLPROXY_H
  15. #include "TblProxy.h"
  16. #endif
  17.  
  18. #ifndef TBLPART_H
  19. #include "TblPart.h"
  20. #endif
  21.  
  22. #ifndef TBLFRAME_H
  23. #include "TblFrame.h"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWITERS_H
  33. #include "FWIters.h"
  34. #endif
  35.  
  36. #ifndef FWUTIL_H
  37. #include "FWUtil.h"
  38. #endif
  39.  
  40. #ifndef FWFCTCLP_H
  41. #include "FWFctClp.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. // ----- OS Includes -----
  49.  
  50. #ifndef FWODGEOM_H
  51. #include "FWODGeom.h"
  52. #endif
  53.  
  54. #ifndef FWFXMATH_H
  55. #include "FWFxMath.h"
  56. #endif
  57.  
  58. //========================================================================================
  59. // RunTime Info
  60. //========================================================================================
  61.  
  62. #ifdef FW_BUILD_MAC
  63. #pragma segment odfTable
  64. #endif
  65.  
  66. //========================================================================================
  67. //    class CTableProxy
  68. //========================================================================================
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    CTableProxy::CTableProxy
  72. //----------------------------------------------------------------------------------------
  73.  
  74. CTableProxy::CTableProxy(Environment* ev, CTablePart* tablePart, FW_CPresentation* presentation) :
  75.     FW_MProxy(ev, tablePart, presentation),
  76.     fTablePart(tablePart),
  77.     fCell(0, 0)
  78. {
  79.     SetSelectState(ev, TRUE);
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    CTableProxy::~CTableProxy
  84. //----------------------------------------------------------------------------------------
  85.  
  86. CTableProxy::~CTableProxy()
  87. {
  88. }
  89.  
  90. //----------------------------------------------------------------------------------------
  91. //    CTableProxy::UsedShapeChanged
  92. //----------------------------------------------------------------------------------------
  93.  
  94. void CTableProxy::UsedShapeChanged(Environment *ev,
  95.                                    FW_CEmbeddingFrame* embeddingFrame,
  96.                                    ODFrame* odEmbeddedFrame)
  97. {
  98.     FW_CRect cellRect;
  99.     fTablePart->FindRect(fCell, cellRect);
  100.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev, cellRect);
  101.  
  102.     FW_CAcquiredODShape aqUsedShape(FW_CopyAndRelease(ev, odEmbeddedFrame->AcquireUsedShape(ev, NULL)));
  103.         
  104.     // ----- For the Table part, all embedded facets have the same externalTransform
  105.     ODFacet *facet;
  106.     {
  107.         FW_CODFrameFacetIterator ite(ev, odEmbeddedFrame);
  108.         facet = ite.First(ev);
  109.     }
  110.     if (facet == NULL)
  111.         return;
  112.     
  113.     {
  114.         FW_CAcquiredODTransform aqExternalTransform(facet->AcquireExternalTransform(ev, NULL));
  115.         aqUsedShape->Transform(ev, aqExternalTransform);
  116.         aqInvalidShape->Subtract(ev, aqUsedShape);
  117.     }
  118.     
  119.     // ----- Invalidate
  120.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  121.     
  122.     // ----- Recalculate the clip
  123.     FW_CFacetClipper facetClipper(ev, fTablePart);
  124.     facetClipper.Clip(ev, GetPresentation(ev), NULL);
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    CTableProxy::FrameShapeRequested
  129. //----------------------------------------------------------------------------------------
  130.  
  131. ODShape* CTableProxy::FrameShapeRequested(Environment* ev, 
  132.                                         ODFrame* odEmbeddedFrame, 
  133.                                         ODShape* askedFrameShape)
  134. {
  135. FW_UNUSED(askedFrameShape);
  136.  
  137.     FW_CRect cellRect;
  138.     fTablePart->FindRect(fCell, cellRect);
  139.  
  140.     cellRect.Place(FW_kZeroPoint);
  141.     ODShape* cellShape = ::FW_NewODShape(ev, cellRect);
  142.     
  143.     return cellShape;
  144. }
  145.  
  146. //----------------------------------------------------------------------------------------
  147. //    CTableProxy::MoveEmbeddedFrames
  148. //----------------------------------------------------------------------------------------
  149.  
  150. void CTableProxy::MoveEmbeddedFrames(Environment* ev, const CCell& destCell)
  151. {
  152.     FW_CRect rect;
  153.     fTablePart->FindRect(destCell, rect);
  154.     ChangeFrameShapes(ev, rect.Width(), rect.Height());
  155.     ChangeExternalTransforms(ev, rect.left, rect.top);
  156.     
  157.     //     [HLX] because I can't create facets with a NULL clip (bug in OpenDoc) I have to 
  158.     //    Clip my embedded facets everytime
  159.     FW_CFacetClipper facetClipper(ev, fTablePart);
  160.     facetClipper.Clip(ev, GetPresentation(ev), NULL);
  161. }
  162.  
  163. //----------------------------------------------------------------------------------------
  164. //    CTableProxy::ChangeLinkStatus
  165. //----------------------------------------------------------------------------------------
  166.  
  167. void CTableProxy::ChangeLinkStatus(Environment* ev, ODLinkStatus linkStatus)
  168. {
  169.     FW_CProxyProxyFrameIterator iter(this);
  170.     for (FW_CProxyFrame* frame = iter.First(); iter.IsNotComplete(); frame = iter.Next())
  171.     {
  172.         if (linkStatus == kODInLinkSource)
  173.         {    // if frame is already in a destination, leave its status alone
  174.             if (frame->GetFrame(ev)->GetLinkStatus(ev) != kODInLinkDestination)
  175.                 frame->GetFrame(ev)->ChangeLinkStatus(ev, linkStatus);
  176.         }
  177.         else
  178.             frame->GetFrame(ev)->ChangeLinkStatus(ev, linkStatus);
  179.     }
  180. }
  181.